{layout name="layout/food" /}
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">二维码列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    {if $qrcode['rule']}
                    <div class="am-u-sm-12 am-u-md-3">
                        <div class="am-form-group">
                            <div class="am-btn-group am-btn-group-sm">
                                <a href="javascript:void(0);" class="hema-add am-btn am-btn-primary am-radius">
                                    <span class="am-icon-plus"></span> 添加
                                </a>
                            </div>
                        </div>
                    </div>
                    {else/}
                    <div class="tips am-margin-bottom-sm am-u-sm-12">
                        <div class="pre-error">
                            <p>普通二维码规则初始化失败，无法创建普通二维码</p>
                        </div>
                    </div>
                    {/if}
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>二维码</th>
                                <th>类型</th>
                                <th>餐桌</th>
                                <th>门店</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if sizeof($list) > 0}
                                {foreach $list as $item}
                                <tr>
                                    <td class="am-text-middle">{$item['qrcode_id']}</td>
                                    <td class="am-text-middle">
                                        <a href="/qrcode/food/{$item['qrcode_id']}.png" title="点击查看大图" target="_blank">
                                            <img src="/qrcode/food/{$item['qrcode_id']}.png" width="50" height="50" alt="普通二维码图片">
                                        </a>
                                    </td>
                                    <td class="am-text-middle">{$item['type']['text']}</td>
									<td class="am-text-middle">
									    {$item['table']['table_name']?$item['table']['table_name']:'--'}
									</td>
                                    <td class="am-text-middle">
                                        {$item['shop']['shop_name']?$item['shop']['shop_name']:'--'}
                                    </td>
                                    <td class="am-text-middle">{$item['create_time']}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="{:url('food.shop.qrcode/edit',['id' => $item['qrcode_id']])}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="hema-del tpl-table-black-operation-del"
                                               data-id="{$item['qrcode_id']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="7" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
                    <div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="food/shop/qrcode/add" /}
<script src="/assets/plugins/vue/vue.min.js?v={$version}"></script>
<script>
    $(function () {
         //添加
        $('.hema-add').on('click', function () {
            $.showAction({
                title: '批量生成普通二维码', 
                area: '750px', 
                content: template('tpl-add', {}), 
                uCheck: true, 
                success: function ($content) {
                    $('#my-form').formPost({
                        url: "{:url('food.shop.qrcode/add')}"
                    });
                }, 
                btn2: function ($content) {
                    return true;
                }
            });
        });
        // 删除元素
        var url = "{:url('food.shop.qrcode/delete')}";
        $('.hema-del').del('id', url);

    });
</script>

